﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter3.Section2
{
    public class Example03
    {
        public Example03()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double[], double> f
                = new V.Function.ToLastType<double[], double>(func);
            double[] at = { 1.0, Math.PI/2.0 };
            double[] h = { 0.01, 0.03 };
            V.TaylorFormula obj = new V.TaylorFormula(f, at, h);
            obj.Compute();
            result += obj.Result.ToString() + "\r\n";
            result += (1.0 - Math.PI*Math.PI/8.0*h[0]*h[0]
                - Math.PI / 2.0 * h[0] * h[1]
                - 1.0/2.0 * h[1] * h[1] ).ToString() + "\r\n";
        }
        private double func(double[] x)
        {
            return Math.Sin(x[0] * x[1]);
        }
    }
}
// 0.998955391047147
// 0.998955391046948
